<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps JavaScript API Example</title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=abcdefg&sensor=true_or_false"
            type="text/javascript"></script>
    <script type="text/javascript">


    //funçao que mostra mapa quando é feito o load da pagina
    function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(38.4094, -122.8290), 13);
        map.setUIToDefault();
            
      }
    }
    
    
    //ler do textbox html e passar o argumento pra procurar no google maps
    function  readFormShow(){
        var address = document.getElementById("firstname").value;
        showAddress(address);
    }
    
    //funçao que atravez do nome mostra no mapa
    function showAddress(address) {
      var map = new GMap2(document.getElementById("map_canvas"));
      var geocoder = new GClientGeocoder();
      geocoder.setBaseCountryCode("PT");
      geocoder.getLatLng(
        address,
        function(point) {
          if (!point) {
            alert(address + " not found");
          } else {
            map.setCenter(point, 13);
            var marker = new GMarker(point);     
            map.addOverlay(marker);
            marker.openInfoWindowHtml(address);  // bom para mostrar os anuncios
          }
        }
      );
    }

    </script>
  </head>
  <!--<body onload="initialize()" onunload="GUnload()">-->
  <body onload="initialize()" onunload="GUnload()">
  <form>
        Endereço:
        <input type="text" name="firstname" id="firstname"/>
        <input type="button" value="Click Me" onclick="readFormShow()"/>
        </form>
    <div id="map_canvas" style="width: 500px; height: 300px"> </div>
  </body>
</html>


	